package com.ricchieri.service;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Transactional;

import com.ricchieri.dao.interf.IScheduleCharterExpenseTypeDao;
import com.ricchieri.filter.BasicFilter;
import com.ricchieri.model.ScheduleCharterExpenseType;
import com.ricchieri.service.interf.IScheduleCharterExpenseTypeService;
import com.ricchieri.util.FacesUtil;

@Transactional(readOnly = true)
public class ScheduleCharterExpenseTypeService implements IScheduleCharterExpenseTypeService, Serializable {
	private static final long serialVersionUID = -7638124746778605179L;
	IScheduleCharterExpenseTypeDao expenseTypeDao;
	
	@Override
	@Transactional(readOnly = true)
	public List<ScheduleCharterExpenseType> getAllExpenseType() {
		BasicFilter filter = new BasicFilter();
		return expenseTypeDao.getAllExpenseType(filter);
	}

	public IScheduleCharterExpenseTypeDao expenseTypeDao() {
		return expenseTypeDao;
	}

	public void setExpenseTypeDao(IScheduleCharterExpenseTypeDao expenseTypeDao) {
		this.expenseTypeDao = expenseTypeDao;
	}
	
	@Override
	public Map<String, String> getComboScheduleCharterExpenseType() {
		List<ScheduleCharterExpenseType> expensesTypeValues = this.getAllExpenseType();

		Map<String, String> trips = new LinkedHashMap<String, String>();

		for (ScheduleCharterExpenseType expensesType : expensesTypeValues) {
			trips.put(FacesUtil.getMessage(expensesType.getDescription()), String.valueOf(expensesType.getId()));
		}

		return trips;
	}
	
	@Override
	public ScheduleCharterExpenseType getScheduleCharterExpenseTypeById(BasicFilter expenseTypeFilter) {
		return expenseTypeDao().getScheduleCharterExpenseTypeById(expenseTypeFilter);
	}
}
